<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/general.xhtml">

	<ui:define name="title">
		<h:outputText value="Edit Static Data1" />
	</ui:define>

	<ui:define name="content">
		<h:form enctype="multipart/form-data" id="form">
		
		
			<p:tabMenu activeIndex="1">
		        <p:menuitem value="Add New Results" url="new"/> 
		        <p:menuitem value="Edit Static Data" url="edit"/>  
	        </p:tabMenu>


			<table border="1px" style="margin: 10px 1%; width: 98%">
				<thead>
					<row>
						<td>
							<h3>Table List</h3>
						</td>
						<td>
							<p:commandButton value="Add Row" actionListener="#{testSummaryTable.render}" update="form" />
							<p:commandButton value="Delete" onclick="confirmation.show()" />
							<p:commandButton value="Commit" title="Commit to Database" actionListener="#{testSummaryTable.commit}" update="form"/>
						</td>
					</row>
				</thead>
				<tbody>
					<th rowspan="9" style="text-align: left; vertical-align: top;">
						<p:tieredMenu style="width: 300px">
					        <p:menuitem value="PERF_PROJECTNAME" action="projectname" />
					        <p:menuitem value="PERF_SCENARIO_TYPE" action="testSummarytype" />
							<p:menuitem value="PERF_SCENARIO" action="scenario" />
							<p:menuitem value="PERF_TRANSACTION_TYPE" action="transactiontype" />
							<p:menuitem value="PERF_TRANSACTIONNAME" action="transactionname" />
							<p:menuitem value="PERF_TESTSUMMARY" disabled="true" />
							<p:menuitem value="PERF_TESTSUMMARY_DATA" action="testsummarydata" />
							<p:menuitem value="PERF_TESTRESULTS" action="testresults" />
							<p:menuitem value="PERF_TESTRAWRESULTS" action="testrawresults" />
					    </p:tieredMenu>
					</th>
					<td>
						<p:scrollPanel style="width:1500px; height:700px">
						<p:dataTable id="testSummary_table" var="testSummary" value="#{testSummaryTable.testSummaryModel}" 
									selection="#{testSummaryTable.selectedTestSummary}" editable="true" 
									editMode="cell" resizableColumns="true" liveResize="true" paginator="true" rows="10" 
									paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                 					rowsPerPageTemplate="10,50,100"  scrollable="true" scrollHeight="580">
							<p:ajax event="cellEdit" listener="#{testSummaryTable.onCellEdit}" />
							<p:column selectionMode="multiple" style="width:2%" />
						
							<p:column headerText="TESTSUMMARY_ID">
								<h:outputText value="#{testSummary.TESTSUMMARY_ID}" />
							</p:column>
						
							<p:column headerText="PROJECT_ID">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.PROJECT_ID}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.PROJECT_ID}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>
							
							<p:column headerText="SCENARIO_ID">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.SCENARIO_ID}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.SCENARIO_ID}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>
							
							<p:column headerText="SCENARIO_TYPE_ID">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.SCENARIO_TYPE_ID}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.SCENARIO_TYPE_ID}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>
							
							<p:column headerText="BRANCH_ID">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.BRANCH_ID}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.BRANCH_ID}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>
							
							<p:column headerText="BUILD_NUMBER">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.BUILD_NUMBER}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.BUILD_NUMBER}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>
							
							<p:column headerText="STATE">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.STATE}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.STATE}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>
							
							<p:column headerText="STARTTIME">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.STARTTIME}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.STARTTIME}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>
							
							<p:column headerText="BASELINE">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.BASELINE}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.BASELINE}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>

							<p:column headerText="COMMENTS">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{testSummary.COMMENTS}" /></f:facet>  
				                   <f:facet name="input"><p:inputText value="#{testSummary.COMMENTS}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>

						</p:dataTable> 
						
						<p:panelGrid id="add" columns="2" rendered="#{testSummaryTable.renderAddRow}" style="width: 100%">

							<f:facet name="header">  
						        Add Row
						    </f:facet>
						    
							<h:outputLabel for="f1" value="TESTSUMMARY_ID" />
							<h:outputLabel for="f2" value="PROJECT_ID" />
							<h:outputLabel for="f3" value="SCENARIO_ID" />
							<h:outputLabel for="f4" value="SCENARIO_TYPE_ID" />
							<h:outputLabel for="f5" value="BRANCH_ID" />
							<h:outputLabel for="f6" value="BUILD_NUMBER" />
							<h:outputLabel for="f7" value="STATE" />
							<h:outputLabel for="f8" value="STARTTIME" />
							<h:outputLabel for="f9" value="BASELINE" />
							<h:outputLabel for="f10" value="COMMENTS" />
							
							<p:inputText id="f1" value="#{testSummaryTable.TESTSUMMARY_ID}" />
							<p:inputText id="f2" value="#{testSummaryTable.PROJECT_ID}" />
							<p:inputText id="f3" value="#{testSummaryTable.SCENARIO_ID}" />
							<p:inputText id="f4" value="#{testSummaryTable.SCENARIO_TYPE_ID}" />
							<p:inputText id="f5" value="#{testSummaryTable.BRANCH_ID}" />
							<p:inputText id="f6" value="#{testSummaryTable.BUILD_NUMBER}" />
							<p:inputText id="f7" value="#{testSummaryTable.STATE}" />
							<p:inputText id="f8" value="#{testSummaryTable.STARTTIME}" />
							<p:inputText id="f9" value="#{testSummaryTable.BASELINE}" />
							<p:inputText id="f10" value="#{testSummaryTable.COMMENTS}" />

							<f:facet name="footer">
								<p:commandButton value="Add" actionListener="#{testSummaryTable.newTestSummaryType}" update="testSummary_table" />
							</f:facet>
						</p:panelGrid>
						</p:scrollPanel>
					</td>
				</tbody>
			</table>
			
			
			<p:commandButton value="Exit" title="Rollback Changes" actionListener="#{testSummaryTable.exit}" update="testSummary_table" style="position: relavite; left: 90%;" />

			<p:confirmDialog id="confirmDialog"
				message="Are you sure you want to delete selected rows?"
				header="Delete selected rows" severity="alert"
				widgetVar="confirmation">

				<p:commandButton id="confirm" value="Yes" update=":form:testSummary_table"
					actionListener="#{testSummaryTable.deleteSelected}" oncomplete="confirmation.hide()"
					 />
				<p:commandButton id="decline" value="Cancel"
					onclick="confirmation.hide()" type="button" />

			</p:confirmDialog>

			<p:messages id="messages" showDetail="false" autoUpdate="true"/> 
		</h:form>
	</ui:define>

</ui:composition>